<?php


namespace app\admin\controller;


class Profile extends Common
{
    public function info(){
        $data=db('admin')->where('id',session('id'))->find();
        $this->assign('user',$data);
        if(request()->isPost()){
            $usrInfo=input('post.');
            $usrInfo['password']=md5($usrInfo['password']);
            $res=\app\admin\model\Admin::update($usrInfo);

            if($res){
                session(null);
                $this->success('修改成功请重新登录','/login');
            }else{
                $this->error("修改失败");
            }
        }
        return $this->fetch("layout/info");
    }
}